package com.tank.netty.http;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

/**
 * Created with IntelliJ IDEA.
 * User: SuQiEr
 * Date:2017/5/13 0013
 * Time: 下午 9:54
 * To change this template use File | Settings | File Templates.
 */
@Slf4j
public class TestService {

    @Test
    public  void start() throws InterruptedException {

        //master
        EventLoopGroup masterGroup = new NioEventLoopGroup();
        //worker
        EventLoopGroup workerGroup = new NioEventLoopGroup();

        try{
            ServerBootstrap serverBootstrap = new ServerBootstrap();
            serverBootstrap.group(masterGroup, workerGroup)
            .channel(NioServerSocketChannel.class)
            .childHandler(new ServiceInit());

            ChannelFuture future = serverBootstrap.bind(8080).sync();
            future.channel().closeFuture().sync();
        }finally {
            masterGroup.shutdownGracefully();
            workerGroup.shutdownGracefully();
        }

    }
    //转换服务器主机地址
    public static void main(String[] args) {
        //网络地址 主机地址
        long value = (256 * 120) + 15;
        System.out.println("value:"+value);
        long d = value % 256;
        long c = (value-d)/256;
        System.out.println(c+"."+d);
    }
}
